import numpy as np
import sys
from PIL import Image
from np2c_header import np2c_header

#####################################################
SAVED_FILE  = 'lenet5_on_mnist.pth'
EXPORT_PATH = '../export'
#####################################################

if __name__ == "__main__":
    if not len(sys.argv)==2:
        print("Usage: {} img_file".format(sys.argv[0]))
        exit(0)
    ########### run model ###########
    img = Image.open(sys.argv[1]).convert("L").resize((32,32))
    input_data = np.array((255. - np.array(img))/255. * 2 - 1)
    input_data = np.expand_dims(input_data, 0)
    print(input_data.shape)
    np2c_header(input_data, "img_in")